package com.example.demo.common;

import org.springframework.util.StringUtils;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-06-11
 * Time: 9:46
 */

// 文章截取工具
public class AbstractContentTools {
    /**
     * @param val       需要截取的字符串
     * @param maxLength 允许的最大摘要长度
     * @return 是否截取的字符串
     */
    public static String SubContent(String val, int maxLength) {
        if (!StringUtils.hasLength(val) || maxLength <= 0) return val;
        if (val.length() <= maxLength) return val;
        return val.substring(0, maxLength);
    }
}